//
//  YongQingConfigVC.swift
//  YongQingFont
//
//  Created by 李东 on 2024/4/20.
//

import UIKit

class YongQingConfigVC: UIViewController {

    @IBOutlet weak var pickerView: UIPickerView!
    
    var selectRow = 0
    
    var selectCallBack:((Int) -> Void)?
    
    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .black.withAlphaComponent(0.5)
        pickerView.delegate = self
        pickerView.dataSource = self
 
    }

    
    @IBAction func cancelHandle(_ sender: Any) {
        dismiss(animated: true)
    }
    
    @IBAction func finishHandle(_ sender: Any) {
        dismiss(animated: true)
        selectCallBack?(selectRow + 1)
    }
}
extension YongQingConfigVC: UIPickerViewDelegate, UIPickerViewDataSource {
    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        1
    }
    
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        50
    }
    
    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        "\(row+1)"
    }
    
    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        selectRow = row
    }
    
    func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
        40
    }
}
